Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
<?php | |
// Source: http://www.carronmedia.com/uk-postal-counties-list | |
array( | |
'England' => array( | |
'Avon', | |
'Bedfordshire', | |
'Berkshire', | |
'Buckinghamshire', |
<head>((?!</head>).|\n)+</head> |
mogrify -path ./output -distort barrel '0.06335 -0.18432 -0.10618' ./*.JPG |
<?php | |
namespace App\Console\Commands\Telescope; | |
use Illuminate\Console\Command; | |
use Illuminate\Support\Facades\DB; | |
use Laravel\Telescope\EntryType; | |
class CustomTelescopePrune extends Command | |
{ |
# -*- coding: utf-8 -*- | |
from django.db.models import signals | |
from django.utils.functional import curry | |
from rest_framework import authentication | |
class UserstampMiddleware(object): | |
"""Add user created_by and updated_by foreign key refs to any model automatically. | |
Almost entirely taken from https://github.com/Atomidata/django-audit-log/blob/master/audit_log/middleware.py""" | |
def process_request(self, request): |
<?php | |
namespace Application\BaseBundle\Doctrine\Listener; | |
use Doctrine\ORM\Event\LoadClassMetadataEventArgs; | |
class InheritanceMapping | |
{ | |
protected $mappings; |
The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).
My take-aways are:
You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.
Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse
# You need #import <objc/runtime.h> | |
#ifdef DEBUG | |
void pspdf_swizzle(Class c, SEL orig, SEL new) { | |
Method origMethod = class_getInstanceMethod(c, orig); | |
Method newMethod = class_getInstanceMethod(c, new); | |
if(class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) { | |
class_replaceMethod(c, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); | |
}else { |
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use File::Find; | |
use File::Spec::Functions qw(rel2abs); | |
use File::Basename; | |
use Cwd; | |
my $dir = dirname(rel2abs($0)); |